package com.simon.seckill.unit;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.util.HashMap;

@Component
@Scope("prototype")
public class RestResultUnit extends HashMap<String, Object> {

    public RestResultUnit ok() {
        this.put("code", 0);
        this.put("msg", "success");
        return this;
    }

    public RestResultUnit error(int code, String msg) {
        this.put("code", code);
        this.put("msg", msg);
        return this;
    }
}